Component({
    data: {
        selected: 0,
        list: [
            {
                icon: 'home-o',
                text: '首页',
                url: '/pages/home/home'
            },
            {
                icon: 'chat-o',
                text: '消息',
                url: '/pages/message/message'
            },
            {
                icon: 'desktop-o',
                text: '工作台',
                url: '/pages/worktable/worktable'
            },
            {
                icon: 'vip-card-o',
                text: '客户',
                url: '/pages/customer/customer'
            },
            {
                icon: 'contact',
                text: '我的',
                url: '/pages/mine/mine'
            },
        ]
    },

    methods: {
        onChange(event) {
      this.setData({ active: event.detail });
            wx.switchTab({
                url: this.data.list[event.detail].url
            });
        },

        init() {
      const page = getCurrentPages().pop();
            this.setData({
                active: this.data.list.findIndex(item => item.url === `/${page.route}`)
            });
        }
    }
});